Chart Class Using Smart XLS

by ssi 25. December 2015 16:58
using SmartXLS;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
 
namespace ChartClass
{
    public class clsPROD_DbSizeChart
    {
        private string sStartRange;
        private string sEndRange;
        private string sRngTotal;
 
        public string _acct = "_($* #,##0_);_($* (#,##0);_($* \"-\"??_);_(@_)",
               _noterate = "#,##0.000_);(#,##0.000);_($* \"-\"??_)",
               _currency = "$#,##0.00_);($#,##0.00)",
               _txt = "@",
               _date = "m/d/yyyy",
               _general = "General",
               _generalNumber = "#,##0;(#,##0);_(* \"-\"??_)",
               _intNumber = "#,##0;(#,##0);_(* \"-\"??_)",
               _genNum3 = "#,##0.000;(#,##0.000);_(* \"-\"??_)",
               _percent = "#,##0.00%;(#,##0.00%);_(* \"-\"??_)";
 
        public List<ChartData> CHARTDATA { getset; }
        public string ReportingClassName { getset; }
        public bool ExcelTableFormat { getset; }
        public string CallingAppVersion { getset; }
        public int LoanCount { getset; }
        public string CallingApp { getset; }
        public string ResultType { getset; }
 
        public string RunNote { getset; }
 
        public string ConnectionString { getset; }
 
        public string ReportTitle { getset; }
 
        public string User { getset; }
 
        public string Version { getset; }
 
        public string PageNumber { getset; }
 
        public string ExportPathName { getset; }
 
        public DateTime StartDate { getset; }
 
        public DateTime EndDate { getset; }
 
        public int SheetNumber { getset; }
        public int LastXDays { getset; }
 
        public string SheetName { getset; }
 
        #region Constructor
 
        public clsPROD_DbSizeChart(string sConnect)
        {
            ConnectionString = sConnect;
            // LOG = swLog;
        }
 
        #endregion Constructor
 
        public void ProcessMe(WorkBook wb)
        {
            //format
            //http://msdn.microsoft.com/en-us/library/0c899ak8.aspx
            // WorkBook wb;
            DateTime dStart = StartDate;
            DateTime dEnd = EndDate;
            // string StartRange, eRange, rngTotal;
            decimal nStart;
            bool b = decimal.TryParse(dStart.ToString("yyyyMMdd"), out nStart);
            decimal nEnd;
            b = decimal.TryParse(dEnd.ToString("yyyyMMdd"), out nEnd);
 
            //AMCSupportDataClassesDataContext dcSupport = new AMCSupportDataClassesDataContext(clsCommonStatics.GetSupportConnectionString());
 
        
 
            #region ExcelExport
 
            wb.NumSheets = SheetNumber + 1;
            wb.setSheetName(SheetNumber, SheetName);
            wb.Sheet = SheetNumber;
            double nMarBot = wb.PrintBottomMargin;
            double nMarTop = wb.PrintTopMargin;
            double nMarRt = wb.PrintRightMargin;
            double nMarLt = wb.PrintLeftMargin;
 
            wb.PrintHeader = "";
            wb.PrintFooterMargin = .25d;
            wb.PrintBottomMargin = .5d;
            wb.PrintTopMargin = .25d;
            wb.PrintRightMargin = .25d;
            wb.PrintLeftMargin = .25d;
            wb.PrintGridLines = true;
            wb.PrintScaleFitVPages = 2;
            wb.PrintScaleFitHPages = 1;
            wb.PrintScaleFitToPage = true;
            wb.PrintHCenter = true;
            wb.PrintTitles = "$1:$4,$C:$C"//Not  sure  about the $C:$C part
            wb.setPrintPaperSize((int)(8.5 * 1440), (int)(14 * 1440));
            int nTopFreezeRow = 0;
            int nIgnore = 0;
            int nBottomFreezeRow = 4;
            wb.freezePanes(nTopFreezeRow, nIgnore, nBottomFreezeRow, nIgnore, false);
            wb.PrintLandscape = true;
            RangeStyle rs = wb.getRangeStyle();
 
            int nCol = 0;
            int nRow = 0;
 
          VS201300.clsSXFormatter oFrm = new VS201300.clsSXFormatter(wb);
 
            int nLastCol = 4;
            oFrm.HorizontalAlignment = RangeStyle.HorizontalAlignmentCenterAcrossCells;
            oFrm.Pattern = RangeStyle.PatternSolid;// 1;
            oFrm.PatternFG = Color.MidnightBlue.ToArgb();
            oFrm.FontColor = Color.White;
 
            string[] aHeader =  {
                                  "Date DownLoaded"
                                 ,"File Size"
                                                          };
 
            oFrm.WriteText(ReportTitle, nRow, 0, nRow, aHeader.Length - 1, true, 12, false);
            nRow++;
            oFrm.WriteText(string.Format("Date Range: {0:d} to {1:d}", StartDate, EndDate), nRow, 0, nRow, aHeader.Length - 1, true, 10, false);
            nRow++;
            oFrm.WriteText(string.Format("Run Date: {0:d}"DateTime.Today), nRow, 0, nRow, aHeader.Length - 1, true, 10, false);
            nRow++;
 
            oFrm.WriteText("", nRow, 0, nRow, aHeader.Length - 1, true, 10, false);
 
            nCol = 0;
 
            nCol = 1;
            nCol = 0;
            oFrm.Wrap = true;
            foreach (string s in aHeader)
            {
                oFrm.WriteText(s.Replace("_"" "), nRow, nCol, nRow, nCol, true, 10, true);
                nCol++;
            }
            oFrm.Pattern = RangeStyle.PatternNull;
            oFrm.FontColor = Color.Black;
            oFrm.HorizontalAlignment = RangeStyle.HorizontalAlignmentLeft;
            oFrm.Wrap = false;
            nRow++;
 
            nCol = 0;
            int nLoanCount = 0;
            int nStartRow = nRow;
            int nEndRow = nRow;
            var Sorted = CHARTDATA.OrderBy(r => r.Label);
            int nChartStartRow = nRow;
            foreach (var ln in Sorted)
            {
                oFrm.HorizontalAlignment = RangeStyle.HorizontalAlignmentLeft;
 
                oFrm.WriteText(string.Format("{0}", ln.Label), nRow, nCol, nRow, nCol, false, 10, false);
                wb.setColWidth(nCol, 35 * 256);
                nCol++;
             
 
                oFrm.WriteNumber((double)ln.Value, nRow, nCol, nRow, nCol, false, 10, _genNum3);
                wb.setColWidth(nCol, 20 * 256);
                nCol++;
 
                nEndRow = nRow;
                nRow++;
 
                nCol = 0;
                nLoanCount++;
            }
 
            int nChartEndRow = nEndRow + 1;
 
            int nBottomVertRow = nRow - 1;
 
            #endregion ExcelExport
 
            //  oFrm.WriteText("Loans displayed in red font have not been exported via the GL TRANS report.  The GL TRANS needs to be generated for the date range listed for the loans in red font.", nRow, nCol, nRow, nCol, true, 10, false);
            oFrm.FontColor = Color.Black;
 
            #region UserHouseKeeping
 
            nRow++;
            nRow++;
            nRow++;
 
            VS201300.clsInfo oABt = new VS201300.clsInfo();
            oFrm.WriteText(string.Format("AMC Support Version {0} Report Library Version {1}", Version, oABt.VS2103Version), nRow, 0, nRow, nLastCol, true, 8, false);
       
            #endregion UserHouseKeeping
 
            LoanCount = nLoanCount;
 
          
            wb.Sheet = 0;
 
            #region Chart
 
            //create chart with it's location
            //Columns & Rows
            int left = 3;
            int top = 6;
            int right = 20;
            int bottom = 40;
 
            //create chart with it's location
            ChartShape chart = wb.addChart(left, top, right, bottom);
            chart.ChartType = ChartShape.Line;
 
            string sRange = string.Format("{0}!$A${1}:$B${2}", SheetName, nStartRow, nEndRow);
 
            chart.setLinkRange(sRange, false);
            //set axis title
            chart.setAxisTitle(ChartShape.XAxis, 0, "Date");
            chart.setAxisTitle(ChartShape.YAxis, 0, "Gbytes");
            //set series name
            chart.setSeriesName(0, "File Size");
            //chart.setSeriesName(1, "My Series number 2");
 
            chart.Title = "Download File Size Chart [PROD]";
 
            //set plot area's color to darkgray
            ChartFormat chartFormat = chart.PlotFormat;
            chartFormat.setSolid();
            chartFormat.ForeColor = Color.DarkGray.ToArgb();
            chart.PlotFormat = chartFormat;
 
            //set series 0's color to blue
            ChartFormat seriesformat = chart.getSeriesFormat(0);
            chartFormat.setSolid();
            seriesformat.ForeColor = Color.Red.ToArgb();
            chart.setSeriesFormat(0, seriesformat);
 
            //set series 1's color to red
            //seriesformat = chart.getSeriesFormat(1);
            //seriesformat.setSolid();
            //seriesformat.ForeColor = Color.Red.ToArgb();
            //chart.setSeriesFormat(1, seriesformat);
 
            //set chart title's font property
            ChartFormat titleformat = chart.TitleFormat;
            titleformat.FontSize = 14 * 20;
            titleformat.FontUnderline = true;
            chart.TitleFormat = titleformat;
 
            #endregion Chart
        }
 
      
    }
}

Tags: , , ,

CSharp | linq | SmartXLS

List<>

by ssi 17. December 2015 12:50
List<DocumentTab> THEDOCS = GetDocumentTab();
      private List<DocumentTab> GetDocumentTab()
      {
          List<DocumentTab> DOCAT = new List<DocumentTab>();
          DocumentTab rcd = new DocumentTab();
          rcd.Short_Name = "DOC1";
          rcd.TAB_NAME = "DOC01";
          DOCAT.Add(rcd);
 
          rcd = new DocumentTab();
          rcd.Short_Name = "DOC2";
          rcd.TAB_NAME = "DCO02";
          DOCAT.Add(rcd);
 
          rcd = new DocumentTab();
          rcd.Short_Name = "DOC3";
          rcd.TAB_NAME = "DOC03";
          DOCAT.Add(rcd);
 
          rcd = new DocumentTab();
          rcd.Short_Name = "DOC4";
          rcd.TAB_NAME = "4thDOC";
          DOCAT.Add(rcd);
 
 
 
          return DOCAT;
      }

Tags:

CSharp

List Scheduler Tasks

by ssi 17. December 2015 12:44
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32.TaskScheduler;
using System.Diagnostics.Eventing.Reader;
 
namespace ListSchedulerTasks
{
    class Program
    {
        static string sFolder = "<MS scheduler folder>";
        static List<SchedulerTasks> SCHEDTASK = new List<SchedulerTasks>();
        static void Main(string[] args)
        {
            string sVer = "15.12.15.a";
            Console.WriteLine("{0}", sVer);
            EnumAllTasks();
            Console.WriteLine("{0}""Its over");
 
            foreach (var ts in SCHEDTASK)
                Console.WriteLine("Name: {0} => next{1} en{2} lst{3} res:{4}", ts.Name, ts.NextRunTime, ts.Enabled, ts.LastRunTime, ts.LastTaskResult);
 
            Console.ReadLine();
        }
 
 
        static void EnumAllTasks()
        {
            using (TaskService ts = new TaskService())
                EnumFolderTasks(ts.RootFolder);
        }
 
        static void EnumFolderTasks(TaskFolder fld)
        {
          
            foreach (Task task in fld.Tasks)
                ActOnTask(task);
            foreach (TaskFolder sfld in fld.SubFolders)
                EnumFolderTasks(sfld);
        }
        static void ActOnTask(Task t)
        {
            if (t.Folder.ToString().Contains(sFolder))
            {
 
              //  Console.WriteLine("Name: {0} => next{1} en{2} lst{3} res:{4}", t.Name, t.NextRunTime, t.Enabled, t.LastRunTime, t.LastTaskResult);
 
                SchedulerTasks rcd = new SchedulerTasks();
                rcd.Name = t.Name;
                rcd.NextRunTime = t.NextRunTime;
                rcd.Enabled = t.Enabled;
                rcd.LastRunTime = t.LastRunTime;
                rcd.LastTaskResult = t.LastTaskResult;
                SCHEDTASK.Add(rcd);
 
 
 
            }
 
 
        }
 
 
    }
}
 
 using System;
 
namespace ListSchedulerTasks
{
    internal class SchedulerTasks
    {
        public bool Enabled { getinternal set; }
        public DateTime LastRunTime { getinternal set; }
        public object LastTaskResult { getinternal set; }
        public string Name { getinternal set; }
        public DateTime NextRunTime { getinternal set; }
    }
}

Tags: , ,

CSharp

Load a datagridview using List<> with files in a folder

by ssi 11. November 2013 07:40
      private void LoadGridInFolder()
        {
          string  sMask = "*.*";
            string[] aExcludeExt = { ".DB",".JPG",".BMP",".PNG",".PDF",".TXT",".WMV",".MPEG",".AVI" };
            DirectoryInfo di = new DirectoryInfo(FullQualifiedDocumentFolder);
            List<PolicyDocs> DocRec = new List<PolicyDocs>();

            FileInfo[] DirFiles = di.GetFiles(sMask);
            foreach (FileInfo fi in DirFiles)
            {
                if (!aExcludeExt.Contains(fi.Extension.ToUpper()))
                {
                    PolicyDocs rcd = new PolicyDocs();
                    rcd.FileName = fi.Name;
                    rcd.Docdate = fi.LastAccessTime;
                    rcd.Length = fi.Length;
                    rcd.CreatedDate = fi.CreationTime;
                    rcd.Extension = fi.Extension;
                    rcd.Folder = di.Name;

                    DocRec.Add(rcd);
                }
            }
            dataGridView1.DataSource = DocRec;
            SetColumns(dataGridView1);

            // SetColumns(dataGridView1);
        }

Tags: , ,

CSharp

Calendar

<<  May 2024  >>
MoTuWeThFrSaSu
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

View posts in large calendar

RecentComments

None

Development Team @ Shelbysys

We develop custom database applications for our clients. Our development tool of choice is MS Visual Studio. 

Quotations

"The distance between insanity and genius is measured only by success."
Bruce Feirstein